<?php
require ('../include/init.inc.php');
$holder_name = $holder_id = $holder_stock  = '';
extract ( $_POST, EXTR_IF_EXISTS );

if (Common::isPost ()) {
	$exist = HolderStock::getHolderStockById($holder_id);
	if($exist){
		
		OSAdmin::alert("error",ErrorMessage::STOCK_CONFLICT);
	}else if($holder_name=="" || $holder_id=="" || $holder_stock ==""){
		
		OSAdmin::alert("error",ErrorMessage::NEED_PARAM);
	}else{
		$input_data = array ('holder_name' => $holder_name, 'holder_id' => $holder_id , 'holder_stock' => $holder_stock);
		$holder_id = HolderStock::addStock ( $input_data );
		
		if ($holder_id==0) {
			
			SysLog::addLog ( UserSession::getUserName(), 'ADD', 'holder_stock' ,$holder_id, json_encode($input_data) );
			Common::exitWithSuccess ('账号添加成功','panel/holder_stocks.php');
		}else{
			OSAdmin::alert("error");
		}
	}
}

$holder_id_post = HolderStock::getHolderStockMaxId();
Template::assign("holder_id_post" ,$holder_id_post);
Template::assign("_POST" ,$_POST);
Template::display ( 'panel/holder_stock_add.tpl' );
